package spe.ui.action;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;

import spe.Activator;
import spe.common.ElementUtil;
import spe.model.spem.SPEMElement;
import spe.ui.wizard.DiagramNewWizard;


/**
 * @author: Dao Anh Vu - May 28, 2012
 * @description: 
 * 		This class shows the menu New drop down to create a new
 * 		package, method library, library plugin or other.
 * */
public class NewMenuAction extends Action 
{
	private SPEMElement parentObject = null;
	private int createFor;
	private Shell shell;
	
	public NewMenuAction()
	{
		setId("fileNewDropDown");
		setText("Add new");
		setToolTipText("file.new.tooltip");
		//ImageDescriptor imgdes = RCPUIPlugin.getDefault().getImageDescriptor("icons/new_con.gif");
		ImageDescriptor imgdes = Activator.getImageDescriptorByPath("icons/new_con.gif");
		setImageDescriptor(imgdes);
	}
	
	public NewMenuAction(SPEMElement parentObject, int createFor, Shell shell)
	{
		this.parentObject = parentObject;
		this.shell = shell;
		this.createFor = createFor;
		
		setId("fileNewDropDown");
		setText(ElementUtil.ElementTypeNameMap.get(createFor));
		setToolTipText("file.new.tooltip");
		Platform.getBundle("");
		ImageDescriptor imgdes = null;
		switch(createFor)
		{
			case ElementUtil.METHOD_PLUGIN:
				imgdes = Activator.getImageDescriptorByPath("icons/icon16/MethodPlugin.jpg");
				break;
				
			case ElementUtil.METHOD_CONFIG:
				imgdes = Activator.getImageDescriptorByPath("icons/icon16/MethodPlugin.jpg");
				break;
				
			case ElementUtil.ACTIVITY:
				imgdes = Activator.getImageDescriptorByPath("icons/icon16/Activity.jpg");
				break;
				
			case ElementUtil.CATEGORY:
				imgdes = Activator.getImageDescriptorByPath("icons/icon16/Category.jpg");
				break;
		}
		setImageDescriptor(imgdes);
	}
	
	@Override
	public void run()
	{
		switch(createFor)
		{
			case ElementUtil.METHOD_PLUGIN:
				WizardDialog wizardDialog = new WizardDialog(shell, new DiagramNewWizard());
				wizardDialog.open();
				break;
				
			case ElementUtil.METHOD_CONFIG:
				break;
				
			case ElementUtil.ACTIVITY:
				break;
				
			case ElementUtil.CATEGORY:
				break;
		}
	}
}